]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shell-tray-icon: Use available space when that's defined
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Wed, 1 May 2024 02:18:50 +0000 (04:18 +0200)
committerJeremy Bícha <jbicha@ubuntu.com>
Fri, 12 Jul 2024 22:29:07 +0000 (23:29 +0100)
Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7613
(cherry picked from commit b10bfe1f9ce2b7794103f54bcf249f935678b5f7)

Origin: https://gitlab.gnome.org/3v1n0/gnome-shell/-/commits/tray-offscreen-xwindows
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2012388

Gbp-Pq: Name shell-tray-icon-Use-available-space-when-that-s-defined.patch

src/shell-tray-icon.c
src/tray/na-xembed.c
src/tray/na-xembed.h

index 3eee5f5bf52363861a07d0c5a049bb818d57d49d..e1ff1cd62732c07499c50fdb43bdaf6edc8bf0ef 100644 (file)
@@ -185,6 +185,10 @@ shell_tray_icon_allocate (ClutterActor          *actor,
 
   CLUTTER_ACTOR_CLASS (shell_tray_icon_parent_class)->allocate (actor, box);
 
+  na_xembed_set_available_size (NA_XEMBED (tray_icon->tray_child),
+                                roundf (clutter_actor_box_get_width (box)),
+                                roundf (clutter_actor_box_get_height (box)));
+
   /* Find the actor's new coordinates in terms of the stage.
    */
   clutter_actor_get_transformed_position (actor, &wx, &wy);
index 69690f1a0100cdc828990497bb22e0de1494941b..447c1cbde08e708d85428865e8bec0dfb22f2c9c 100644 (file)
@@ -43,6 +43,8 @@ struct _NaXembedPrivate
   int request_height;
   int current_width;
   int current_height;
+  int available_width;
+  int available_height;
   int resize_count;
   int xembed_version;
 
@@ -141,6 +143,8 @@ na_xembed_end_embedding (NaXembed *xembed)
   priv->current_width = 0;
   priv->current_height = 0;
   priv->resize_count = 0;
+  priv->available_width = -1;
+  priv->available_height = -1;
   g_clear_handle_id (&priv->resize_id, g_source_remove);
 }
 
@@ -186,6 +190,11 @@ na_xembed_synchronize_size (NaXembed *xembed)
   width = priv->request_width;
   height = priv->request_height;
 
+  if (priv->available_width >= 0)
+    width = priv->available_width;
+  if (priv->available_height >= 0)
+    height = priv->available_height;
+
   XMoveResizeWindow (xdisplay,
                      priv->socket_window,
                      x, y,
@@ -747,6 +756,10 @@ na_xembed_class_init (NaXembedClass *klass)
 static void
 na_xembed_init (NaXembed *xembed)
 {
+  NaXembedPrivate *priv = na_xembed_get_instance_private (xembed);
+
+  priv->available_width = -1;
+  priv->available_height = -1;
 }
 
 void
@@ -811,6 +824,22 @@ na_xembed_get_size (NaXembed *xembed,
     *height = priv->request_height;
 }
 
+void
+na_xembed_set_available_size (NaXembed *xembed,
+                              int       width,
+                              int       height)
+{
+  NaXembedPrivate *priv = na_xembed_get_instance_private (xembed);
+
+  if (priv->available_width == width && priv->available_height == height)
+    return;
+
+  priv->available_width = width;
+  priv->available_height = height;
+
+  na_xembed_resize (xembed);
+}
+
 void
 na_xembed_get_root_position (NaXembed *xembed,
                              int      *x,
index ea8f9f44c2c87ec59f017f83b446131854fb96f0..751da97347b755ec91bbec71765bcb9fb6f25ba3 100644 (file)
@@ -59,6 +59,10 @@ void na_xembed_get_size (NaXembed *xembed,
                         int      *width,
                         int      *height);
 
+void na_xembed_set_available_size (NaXembed *xembed,
+                                  int       width,
+                                  int       height);
+
 void na_xembed_set_background_color (NaXembed           *xembed,
                                     const ClutterColor *color);